<template>
  <view class="cardstyle">
    <slot name="header"></slot>
    <view style="display: flex; flex-direction: row; align-items: center;">
      <image src="/static/logo.png" style="width: 50px; height: 60px; margin-right: 10px;"></image>
      <text class="titlebox">{{ title }}</text>
    </view>
    <view class="tipsbox" style="background-color: blue; padding: 8px;">
      <text style="color: #f00;" v-if="isTop">置顶</text>
      <text> {{ author }}</text>
      <text> {{ comments }}评</text>
      <view style="flex: 1; display: flex; justify-content: flex-end;">
        <text>{{ time }}</text>
      </view>
    </view>
    <slot name="tips"></slot>
  </view>
</template>

<script>
export default {
  name: "NewsView",
  props: {
    title: {
      type: String,
      default: "新闻标题"
    },
    isTop: {
      type: Boolean,
      default: false
    },
    author: {
      type: String,
      default: "匿名作者"
    },
    comments: {
      type: Number,
      default: 0
    },
    time: {
      type: String,
      default: "2025-10-25"
    }
  }
}
</script>

<style>
.cardstyle {
  display: flex;
  flex-direction: column;
  text-align: left;
  background-color: #fff;
  border-radius: 10px;
  padding: 10px;
  margin: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.titlebox {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}
.tipsbox {
  font-size: 14px;
  color: #666;
  margin-top: 8px;
}
</style>